package com.lson.kafka.stream.service;

import com.lson.kafka.stream.entity.ProducerMsg;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class StreamProducerService {
    @Autowired
    private Source source;

    public void sendMsg(String status,String id){
        ProducerMsg producerMsg = new ProducerMsg();
        producerMsg.setId(id);
        producerMsg.setStatus(status);
        source.output().send(MessageBuilder.withPayload(producerMsg).build());
    }

}
